<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #ad{
            width: 300px;
            height: 200px;
            background-color: pink;
            position: absolute;
            left: 50%;
            top: 50%;
            margin-left: -150px;
            margin-top: -100px; 
            text-align: center;
            line-height: 200px;
            color: #fff;
            font-size: 100px;
            display: block;
        }
    </style>
</head>
<body>
    <div id="ad">广告
    </div>
    <script>
        //需求：5秒之后，广告自动消除
        //1.获取元素
        var ad = document.getElementById("ad");
        //2.设置定时器
        setTimeout(function(){
            ad.style.display = "none";
        },5000);
     
        
    </script>
</body>
</html>